<template>
  <div>
    <i class="el-icon-arrow-left m-b-20" @click="back"></i>
    <el-descriptions
      title="账单号：1111"
      extra="2022-07-13"
      :column="7"
      :colon="false"
      direction="vertical"
      border
    >
      <el-descriptions-item
        label="团队客户名称"
        label-class-name="my-label"
        content-class-name="my-content"
        >kooriookami</el-descriptions-item
      >
      <el-descriptions-item
        label="联系人"
        label-class-name="my-label"
        content-class-name="my-content"
        >18100000000</el-descriptions-item
      >
      <el-descriptions-item
        label="账单金额（元）"
        label-class-name="my-label"
        content-class-name="my-content"
        >苏州市</el-descriptions-item
      >
      <el-descriptions-item
        label="加注总量（kg）"
        label-class-name="my-label"
        content-class-name="my-content"
        >苏州市</el-descriptions-item
      >
      <el-descriptions-item
        label="状态"
        label-class-name="my-label"
        content-class-name="my-content"
        >苏州市</el-descriptions-item
      >
      <el-descriptions-item
        label="结算时间"
        label-class-name="my-label"
        content-class-name="my-content"
        >苏州市</el-descriptions-item
      >
      <el-descriptions-item
        label="备注"
        label-class-name="my-label"
        content-class-name="my-content"
      ></el-descriptions-item>
    </el-descriptions>
    <div class="m-t-20"></div>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page="page"
      ref="crud"
      v-model="form"
      :permission="permissionList"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @on-load="onLoad"
    >
    </avue-crud>
  </div>
</template>

<script>
import {
  getList,
  getUser,
  remove,
  update,
  add,
  grant,
  resetPassword,
} from "@/api/system/user";
import { mapGetters } from "vuex";

export default {
  data() {
    return {
      form: {},
      box: false,
      props: {
        label: "title",
        value: "key",
      },
      menuGrantList: [],
      dataScopeGrantList: [],
      menuTreeObj: [],
      dataScopeTreeObj: [],
      selectionList: [],
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        border: true,
        index: true,
        selection: false,
        viewBtn: true,
        menu: false,
        header: false,
        height: "auto",
        calcHeight: 220,
        column: [
          { label: "加注单号" },
          { label: "加注机编号" },
          { label: "加注量（kg）" },
          { label: "加注金额（元）" },
          { label: "司机姓名" },
          { label: "加注卡号" },
          { label: "车牌号" },
          { label: "加注时间" },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.role_add, false),
        viewBtn: this.vaildData(this.permission.role_view, false),
        delBtn: this.vaildData(this.permission.role_delete, false),
        editBtn: this.vaildData(this.permission.role_edit, false),
      };
    },
  },
  methods: {
    back() {
      this.$emit("back");
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crud.toggleSelection();
        });
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
  },
};
</script>

<style lang="scss">
.el-descriptions__header {
  background: #f8fafd;
  border: 1px solid #eee;
  line-height: 40px;
  padding: 0 10px;
  margin: 0;
}
.my-label {
  font-weight: bold !important;
  background: #fff !important;
  color: #000 !important;
  border-bottom: 1px solid #eee;
  border-top: 0px solid #eee;
}
</style>
